package example;

public class staticProxyDemo
{
    public static void main(String[] args)
    {
        //真实对象
        You you = new You();
        //代理对象调用真实对象
        WeddingCompany wc = new WeddingCompany(you);
        //代理对象调用结婚
        wc.happyMarry();
    }
}

interface Marry
{
    void happyMarry();
}

//真实角色
class You implements Marry
{
    @Override
    public void happyMarry()
    {
        System.out.println("我结婚了");
    }
}

//代理角色
class WeddingCompany implements Marry
{
    private Marry target;

    public WeddingCompany(Marry target)
    {
        this.target = target;
    }

    @Override
    public void happyMarry()
    {
        before();
        this.target.happyMarry();
        after();
    }

    private void after()
    {
        System.out.println("结婚之后，入洞房");
    }

    private void before()
    {
        System.out.println("结婚之前，布置现场");
    }
}